package org.xjtu.weteam.common.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 自定义异常类，使用方法：throw new CustomException("用户名不能为空");
 * @author Kevin
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class CustomException extends RuntimeException {

    private String message;
    private int code;

    public CustomException(String message) {
        this(message, 400); // 默认错误代码
    }

    @Override
    public String getMessage() {
        return message; // 获取异常消息
    }
}
